//
//  WSMyTopHeader.m
//  WisdomStar
//
//  Created by 谭飞 on 2018/10/22.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "WSMyTopHeader.h"

#import "WSUserInfo.h"

@interface WSMyTopHeader ()

@property (weak, nonatomic) IBOutlet UIImageView *headImage;
@property (weak, nonatomic) IBOutlet UIImageView *sexIconView;
@property (weak, nonatomic) IBOutlet UILabel *nickNameLab;
@property (weak, nonatomic) IBOutlet UILabel *signLab;
@property (weak, nonatomic) IBOutlet UIButton *checkBtn;

// order
@property (weak, nonatomic) IBOutlet UIView *orderContentView;
@property (weak, nonatomic) IBOutlet UIView *orderView1;
@property (weak, nonatomic) IBOutlet UIView *orderView2;
@property (weak, nonatomic) IBOutlet UIView *orderView3;
@property (weak, nonatomic) IBOutlet UIView *orderView4;
@property (weak, nonatomic) IBOutlet UIView *orderView5;

// course
@property (weak, nonatomic) IBOutlet UIView *courseContentView;
@property (weak, nonatomic) IBOutlet UIView *courseItem1;
@property (weak, nonatomic) IBOutlet UIView *courseItem2;
@property (weak, nonatomic) IBOutlet UIView *courseItem3;
@property (weak, nonatomic) IBOutlet UIView *courseItem4;
@property (weak, nonatomic) IBOutlet UIView *courseItem5;

@end

@implementation WSMyTopHeader

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self.headImage setCorners:UIRectCornerAllCorners cornerRadius:self.headImage.xmg_height];
    [self.publishBtn setRoundBorder:[UIColor whiteColor] radius:self.publishBtn.xmg_height];
    
    [self addGestures];
}

- (void)addGestures {
    WEAKSELF
    
    //  我的订单
    /// 查看所有订单
    [self.orderContentView addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.checkAllOrderCallback) {
            weakSelf.checkAllOrderCallback();
        }
    }];
    /// 待付款
    [self.orderView1 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.willPayCallback) {
            weakSelf.willPayCallback();
        }
    }];
    /// 待发货
    [self.orderView2 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.willSendCallback) {
            weakSelf.willSendCallback();
        }
    }];
    /// 待收货
    [self.orderView3 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.willAcceptCallback) {
            weakSelf.willAcceptCallback();
        }
    }];
    /// 已发货
    [self.orderView4 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.didSendCallback) {
            weakSelf.didSendCallback();
        }
    }];
    /// 退款
    [self.orderView5 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.refundCallback) {
            weakSelf.refundCallback();
        }
    }];
    
    //  我的课程
    /// 全部课程
    [self.courseContentView addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.checkAllCallback) {
            weakSelf.checkAllCallback();
        }
    }];
    /// 预约课程
    [self.courseItem1 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.appointmentCallback) {
            weakSelf.appointmentCallback();
        }
    }];
    /// 线下课程
    [self.courseItem2 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.offLineCallback) {
            weakSelf.offLineCallback();
        }
    }];
    /// 直播课程
    [self.courseItem3 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.liveCallback) {
            weakSelf.liveCallback();
        }
    }];
    /// 视频课程
    [self.courseItem4 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.videoCallback) {
            weakSelf.videoCallback();
        }
    }];
    /// 课程订单
    [self.courseItem5 addGestureWithGestureType:WJ_TapGesture completeHandler:^{
        if (weakSelf.courseOrderCallback) {
            weakSelf.courseOrderCallback();
        }
    }];
}

// 发布课程
- (IBAction)publishBtnClick:(id)sender {
    if (self.publishHandle) {
        self.publishHandle();
    }
}

#pragma mark - Setter

- (void)setUserInfo:(WSUserInfo *)userInfo {
    [self.headImage imageWithURL:userInfo.head defaultImage:nil];
//    self.sexIconView.image = userInfo.sex == 0 ? WSImageMake(@"icon_sex_girl_selected") : WSImageMake(@"icon_man");
    self.nickNameLab.text = userInfo.nickname;
    self.signLab.text = STR_Is_NullOrEmpty(userInfo.sign)?[NSString stringWithFormat:@"这个人很懒，啥都没写。"]:[NSString stringWithFormat:@"个性签名：%@",userInfo.sign];
    self.checkBtn.selected = userInfo.is_verify;
}

@end
